<template>
  <div id="box">
    <!-- 搜索栏start -->
    <el-row>
      <el-col :span="22" :push="1">
        <div class="grid-content bg-purple" style="height: 77px">
          <span style="line-height: 77px; font-size: 14px; margin-left: 20px">
            关键词
            <el-input v-model="form.name" size="small" style="width: 150px"></el-input>
          </span>
          <span style="margin-left: 20px">
            <el-button type="primary">搜索</el-button>
            <el-button @click="reset()">重置</el-button>
          </span>
        </div>
      </el-col>
    </el-row>
    <!-- 搜索栏end -->
    <!-- 表格 -->
    <el-row>
      <el-col :span="22" :push="1">
        <div class="grid-content bg-purple">
          <span>
            <el-table :data="tableData" border>
              <el-table-column prop="username" label="员工账号" width="150">
              </el-table-column>
              <el-table-column prop="username" label="员工姓名" width="120">
              </el-table-column>
              <el-table-column prop="className" label="操作模块" width="200">
              </el-table-column>
              <el-table-column prop="method" label="操作内容" width="200">
              </el-table-column>
              <el-table-column prop="ip" label="登录IP" width="120">
              </el-table-column>
              <el-table-column prop="createDate" label="操作时间" width="200">
              </el-table-column>
              <el-table-column label="操作" width="100">
                <template slot-scope="scope">
                  <el-button @click="handleClick(scope.row)" type="text" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="grid-content bg-purple-dark">
              <div class="block">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                  :current-page="pageNum" :page-sizes="[5, 10, 20, 50]" :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper" :total="total">
                </el-pagination>
              </div>
            </div>
          </span>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  data() {
    return {
      form: {},
      pageNum: 1,
      pageSize: 5,
      total: 1,
      tableData: [],
    };
  },
  created() { 
    this.getLogList()
  },
  methods: {
    //查询日志信息
    getLogList() {
      axios.post("/log/findall?pageSize="+this.pageSize+"&pageNum="+this.pageNum).then((res)=>{
        console.log(res)
        this.tableData = res.data.data.records
        this.total = res.data.data.total
      })

    },
    reset() {
      this.form = {};
    },
    //每页条数改变时触发 选择一页显示多少行
    handleSizeChange(val) {
      this.pageSize = val;
      this.getLogList();
    },
    //当前页改变时触发 跳转其他页
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getLogList();
    },
  },
};
</script>

<style scoped>
/* element-ui样式 */
.el-row {
  margin-bottom: 10px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple {
  background: #fff;
  border-radius: 10px;
}

/* 自定义样式 */
/* * {
  margin: 0px;
  padding: 0px;
} */
.box {
  width: 98%;
  height: 100%;
  margin: auto;
  /* background-color: red; */
}

.block {
  padding-top: 20px;
  padding-left: 500px;
}
</style>